package com.xzy.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 通过@Autowired获取HttpServletRequest
 *
 * @author xzy.xiao
 * @date 2023/10/30  9:50
 */
@Slf4j
@RestController
@RequestMapping("/ccc")
public class CccController {

    private final HttpServletRequest autowiredRequest;

    @Autowired
    public CccController(HttpServletRequest autowiredRequest) {
        this.autowiredRequest = autowiredRequest;
    }

    @RequestMapping("/test1")
    public void test1(HttpServletRequest methodRequest) {
        log.info("依赖注入的HttpServletRequest：class = {}", autowiredRequest.getClass());
        log.info("参数注入的HttpServletRequest：class = {}", methodRequest.getClass());
    }
}
